package com.wanshi.lvyouwang.controller;

import com.wanshi.lvyouwang.mapper.AdminMapper;
import com.wanshi.lvyouwang.utils.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author shkstart
 * @create 2021-11-12 14:35
 */
@Controller
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminMapper adminMapper;

    @RequestMapping("/login")
    public String login(){

        return "/WEB-INF/admin/login";
    }
    @RequestMapping("/loginid")
    public String loginID(String adminName,String adminPs){

        List<Admin> admins = adminMapper.findAll();
        for (Admin admin:admins) {
            if (admin.getAdminName().equals(adminName)&&admin.getAdminPs().equals(adminPs)){

                return "/WEB-INF/admin/index.html";
            }
        }
        return "redirect:/admin/login";

    }




}
